
// 内网开发环境接口
const DEVDOMAIN = 'http://192.168.55.134:9002/web-server/'
// 外网测试环境接口
const TESTDOMAIN = 'https://www.yuedone.com/';  //'http://118.178.181.206:9098/'
//const TESTDOMAIN = 'http://118.178.181.206:9098/';
// const TESTDOMAIN = 'http://5ampbp.natappfree.cc/'

// 生产环境接口

const PRODOMAIN = 'https://api.chinaip.art/'

// 资讯测试
const  infoMationUrlDev  ='http://192.168.55.243:8082/'

const  infoMationUrlTest  ='https://testwk.chinadigit.org/'
// 资讯正式
const  infoMationUrlProd  ='https://api.chinaip.art/'



// 静态资源接口地址
const  staticApiTest = 'https://saastestimages.digit.vc//testsaas/13/cdn'
const  staticApiProd = 'https://saasstatic.digit.vc//staticsaas/13/cdn'


//静态资源地址
const staticAdressTest = 'https://www.yuedone.com'
const staticAdressProd = 'https://www.yuedone.com'


// 类型
const miniprogramStateDev = 'developer'
const miniprogramStateTest = 'trial'
const miniprogramStateProd = 'formal'


// 参数配置正式
// const staticAdress = staticAdressProd 
// const API_DOMAIN = PRODOMAIN
// const API_STATIC = staticApiProd
// const INFOMATIONURL = infoMationUrlProd
//const miniprogramState = miniprogramStateProd

// 测试
const staticAdress = staticAdressTest 
const API_DOMAIN = TESTDOMAIN
const API_STATIC = staticApiTest
const INFOMATIONURL = infoMationUrlTest
const miniprogramState = miniprogramStateTest


const UserConfig ={
    'slog':staticAdress +'/common/slogo.png?type=1',//系统logo
    'listChat':staticAdress +'/common/list_chat.png?type=1',//群聊
}

// var ActivityIds = ActivityIdsTest;
var ActivityIds =[];

function getActityDetail(activityId) { //活动id 或者type 类型 取详情
  ActivityIds = getActivityList()

   if(activityId){

    var it = ActivityIds

    var tepm =null;
    for (var i = 0; i <it.length; i++) {

      var item  = it[i];

     if(item.reservationId ==activityId){
      tepm = item 
     
     }else if(item.type==activityId){
      tepm = item 
      
     }

    }

    if(!tepm){
      return ActivityIds[1];
    }
     
     return tepm
   }else{
   }
  
 }


function getTypeActityId(type) { // 或者type 类型取活动id
  ActivityIds = getActivityList()
  if(type){
    for(var i=0;i<ActivityIds.length;i++){
      var item  = ActivityIds[i];
      if(item.type ==type){
        return item.reservationId;
      }
    }
  
  }else{
    return ActivityIds[0].reservationId;
  }

  return ActivityIds[0].reservationId;
}

function setActivityList(list){
  
  ActivityIds =list;
  wx.setStorageSync('activityList', list);
  
  
}

function getActivityList(){
  var list = ActivityIds;

  if(!list||list.length<=0){
    list =  wx.getStorageSync('activityList')
    ActivityIds =list;

  }
  
  return  list;
  
}

function getStaticImgUrl(url) { // 或者type 类型取活动id
  
  console.log('打印传入图片',url)
  if(url){
      return staticAdress + url
  
  }else{
    return '';
  }
}





module.exports = {
  API_DOMAIN,API_STATIC,ActivityIds,getActityDetail,getTypeActityId,getStaticImgUrl,UserConfig,INFOMATIONURL,setActivityList,getActivityList,miniprogramState,staticAdress
}
